package com.xyazm.fulfill.utils;

import com.xyazm.fulfill.domain.entity.OrderFulfillDO;
import com.xyazm.fulfill.domain.entity.OrderFulfillLogDO;
import com.xyazm.fulfill.enums.OrderFulfillOperateTypeEnum;

/**
 * 构建履约单操作日志工具类
 * @author xuyou
 * @date 2023年02月09日 22:06
 */
public class OrderFulfillOperateLogUtil {


    /**
     * 获取履约单操作日志
     */
    public static OrderFulfillLogDO build(OrderFulfillDO orderFulfill, OrderFulfillOperateTypeEnum operateType) {
        Integer fromStatus = operateType.getFromStatus().getCode();
        Integer toStatus = operateType.getToStatus().getCode();
        return create(orderFulfill, operateType.getCode(), fromStatus, toStatus, operateType.getMsg());
    }

    /**
     * 创建履约单操作日志
     */
    private static OrderFulfillLogDO create(OrderFulfillDO orderFulfill,
                                            Integer operateType, int preStatus, int currentStatus,
                                            String operateRemark) {
        OrderFulfillLogDO log = new OrderFulfillLogDO();
        log.setOrderId(orderFulfill.getOrderId());
        log.setFulfillId(orderFulfill.getFulfillId());
        log.setOperateType(operateType);
        log.setPreStatus(preStatus);
        log.setCurrentStatus(currentStatus);
        log.setRemark(operateRemark);
        return log;
    }

}
